#include "worker.h"

worker::worker(QVector<Point> *pointsPtr,double *valueBestNow,QString *tourBestStr,QVector<int> *res,double tInit,double tFinal,double alpha,QMutex *mutex)
{
    this->points=*pointsPtr;
    this->valueBestNow=valueBestNow;
    this->tourBestStr=tourBestStr;
    this->res=res;
    this->tInit=tInit;
    this->tFinal=tFinal;
    this->alpha=alpha;
    this->locker=mutex;
}

void worker::run()
{
    Utils task(this->points,tInit,tFinal,alpha);
    task.runTSP();
    locker->lock();
    if(task.getBestValue()<*valueBestNow){
        *valueBestNow=task.getBestValue();
        *tourBestStr=task.getTourBestStr();
        *res=task.getTourBest();
    }
    locker->unlock();
}
